Export local backend middlewares in proxy server #5852
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
For
local_backend
users with an existing express server already running, who would like to avoid having to run yet another server on another port to have some parts of the functionality work. With this change, it's possible to use the middleware directly, without creating a whole server in a new process:👆 the above works both with express and in a next.js api handler.
Test plan
So, my plan was just to export it to begin with. My hope was that it could be an undocumented part of the API surface of this library and therefore subject to change without a major bump, but it would be useable for those who happen to know it's there.
Having it be an official part of the "real" API surface would be a comparatively change: there would need to be a separate entrypoint for the middleware module part of the library, which doesn't have the side-effect of trying to start a server (and it'd probably be a good idea to generate
.d.ts
files and write documentation, recommended usage, etc., and maybe get rid of the type dependency on winston in the params). And I can't see the harm in just doing this small change for now.Checklist
yarn format
.yarn test
.